package ru.gosoplata.view 
{
	import flash.display.Sprite;
	import flash.events.Event;
	import ru.gosoplata.view.FooterMediator;
	import ru.gosoplata.view.IFooterView;
	import scr.IScreen;
	import uicontrols.ButtonBase;
	/**
	 * ...
	 * @author 
	 */
	public class FooterView extends Sprite implements IFooterView, IScreen
	{
		private var _footerMediator:FooterMediator;
		private var _btnBack:ButtonBase;
		private var _btnMenu:ButtonBase; 
		private var _picCount:uint=0;
		
		public function get btnBack():ButtonBase 
		{
			return _btnBack;
		}
		
		public function get btnMenu():ButtonBase 
		{
			return _btnMenu;
		}
		
		public function FooterView() 
		{
			_btnBack = new ButtonBase("back", 0xFF0000);
			_btnBack.addEventListener(ButtonBase.ON_PIC_LOADED, allPicLoaded);
			addChild(_btnBack);
			_picCount++;
			
			_btnMenu = new ButtonBase("menu", 0xFF0000);
			_btnMenu.addEventListener(ButtonBase.ON_PIC_LOADED, allPicLoaded);
			addChild(_btnMenu);
			_picCount++;
			
			_footerMediator = new FooterMediator(this);
		}
		
		private function allPicLoaded(e:Event):void 
		{
			_picCount--;
			if (_picCount == 0) {
				_btnBack.x = 20;
				_btnBack.y = stage.stageHeight - (_btnBack.height + 20);
				
				_btnMenu.x = stage.stageWidth/2 - _btnMenu.width/2;
				_btnMenu.y = stage.stageHeight - (_btnMenu.height + 20);
			}
		}
		
		/* INTERFACE scr.IScreen */
		
		public function reDraw():void 
		{
			_footerMediator.reDraw();
		}
		
	}

}